package com.next.aappublicapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

import com.google.analytics.tracking.android.EasyTracker;

public class StateElectionMainActivity extends Activity {

	private Button candidateSelectionProcessEnglish;
	private Button candidateSelectionProcessHindi;
	private Button knowYourCandidatesButton;
	private Button knowYourManifesto;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_state_election_main);
		
		candidateSelectionProcessEnglish = (Button)findViewById(R.id.candidateSelectionProcessEng);
		candidateSelectionProcessHindi = (Button)findViewById(R.id.candidateSelectionProcessHindi);
		knowYourCandidatesButton = (Button)findViewById(R.id.knowYourCandidate);
		knowYourManifesto = (Button)findViewById(R.id.knowYourManifesto);
		candidateSelectionProcessEnglish.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				goToCandidateSelectionProcess(true);
				EasyTracker.getTracker().sendEvent("Android", "CandidateSelectionProcess", "English", 1L);
			}
		});
		candidateSelectionProcessHindi.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				goToCandidateSelectionProcess(false);
				EasyTracker.getTracker().sendEvent("Android", "CandidateSelectionProcess", "Hindi", 1L);
			}
		});
		
		knowYourCandidatesButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				
				Intent intent = new Intent(StateElectionMainActivity.this, StateConstituencyCandidateActivity.class);
				StateElectionMainActivity.this.startActivity(intent);
				EasyTracker.getTracker().sendEvent("Android", "DelhiElection", "KnowYourCandidate", 1L);
			}
		});
		
		knowYourManifesto.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				
				Intent intent = new Intent(StateElectionMainActivity.this, StateConstituencyManifestoActivity.class);
				StateElectionMainActivity.this.startActivity(intent);
				EasyTracker.getTracker().sendEvent("Android", "DelhiElection", "KnowYourManifesto", 1L);
			}
		});
		
	}
	private void goToCandidateSelectionProcess(boolean isEnglish){
		Intent intent = new Intent(this, CandidateSelectionProcessActivity.class);
		Bundle bundle = new Bundle();
		bundle.putBoolean(CandidateSelectionProcessActivity.ARGS_IS_ENGLISH, isEnglish);
		intent.putExtra(CandidateSelectionProcessActivity.ARGS_BUNDLE, bundle);
		this.startActivity(intent);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.state_election_main, menu);
		return true;
	}

}
